<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/26
 * Time: 9:36
 */

namespace app\validate;


use think\Validate;

class MemberCert extends Validate
{
    protected $rule =   [
        'name|姓名' => 'require|length:2,4|chs',
        'id_card|身份证号' => 'require|idCard', //身份证号无需验证长度 直接idCard
        'mobile|手机号'  => 'require|mobile',
        'id_card_font|身份证正面' => 'require',
        'id_card_back|身份证背面' => 'require',



//        ['phone', 'require|regex:^1[34578]{1}\d{9}$'],
    ];

    protected $message  =   [
        'name.length' => '姓名请输入2-4位字符',
        'mobile.require' => '请输入手机号',
        'mobile.length' => '请输入11位手机号',
        'mobile.mobile'     => '请输入正确的手机号',
        'mobile.unique'   => '您的账号已在平台注册过',
        'id_card.idCard' => '请输入标准的身份证号',
        'id_card_font.require' => '请上传身份证正面照片',
        'id_card_back.require' => '请上传身份证背面照片',
        'age.require' => '请输入年龄',
        'age.between' => '请输入1-100之间的数字',
        'city.require' => '请输入城市',

        'password.require' => '密码不能为空',
        'password.length' => '密码请输入6-12位长度字符',
        'repassword.confirm' => '两次密码不一致',

        'captcha.require' => '请输入验证码',
        'captcha.number' => '验证码必须是数字',
        'captcha.length' => '请输入6位验证码',
        'old_password.require' => '原密码不能为空',
        'old_password.length' => '原密码密码请输入6-12位长度字符',
        'pay_password.require' => '支付密码不能为空',
        'pay_password.number' => '支付密码必须为数字',
        'pay_password.length' => '支付密码必须为6位字符长度',
        'pay_password.confirm' => '两次支付密码不一致',
//        'old_username.require' => '原手机号不能为空',
//        'old_username.tel'     => '请输入正确的手机号',
        'old_captcha.require' => '原手机号验证码不能为空',
        'old_captcha.number' => '原手机号验证码必须是数字',
        'old_captcha.length' => '请输入6位原手机号验证码',


        'id_number.length' => '请输入正确长度的身份证号',
        'id_number.alphaNum' => '身份证只能包含字母和数字'
    ];


    public function sceneCert(){
        return $this
            ->only(['name','mobile','id_card','id_card_font','id_card_back']);
    }


//
//
//    public function sceneLogin()
//    {
//        return $this->only(['mobile','id_card','password'])
//            ->remove('mobile','unique')
//            ->remove('password','confirm');
//    }
//
//    public function sceneRegister(){
//        return $this->only(['mobile'])
//            ->remove('mobile','unique');
//
//    }


    protected $scene = [
        'mobile' => ['mobile'=> 'require|tel','captcha'=> 'require|number|length:6'],
        'login'  =>  ['mobile' => 'require|tel','password' => 'require|length:6,12'],
        'register' => ['username','password','password_comfirm','captcha'],
        'web_register_data' => ['username','password' => 'require|length:6,12' ,'captcha' => 'require|number|length:6'],
        'register_mini' => ['username' => 'require|tel','password','password_comfirm','captcha'],
        'forget_password' => ['username' => 'require|tel','password' => 'require|length:6,12','captcha'],
        'update_password' => ['old_password','password' => 'require|length:6,12|confirm'], //'username' => 'require|length:6,18',
        'set_pay_password' => ['username' => 'require|tel','captcha','pay_password'],
        'update_username' => ['username','old_captcha','captcha'],
        'cert' => ['name','id_number','phone'],
        'car' => ['name','driver','car_number','car_model']

    ];
}